package cc.sheji.util;

import cn.hutool.crypto.digest.DigestUtil;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

@Component
public class CompareUtil {

    public  boolean compareFiles(String file1, String file2) {
        System.out.println("fileName1:"+file1);
        System.out.println("fileName2:"+file1);

        try {
            FileInputStream fileInputStream1 = new FileInputStream(new File(file1));
            FileInputStream fileInputStream2 = new FileInputStream(new File(file2));
            String s1 = DigestUtil.md5Hex(fileInputStream1);
            String s2 = DigestUtil.md5Hex(fileInputStream2);
            System.out.println(s1);
            System.out.println(s2);
            return s1.equals(s2);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return false;
    }

}
